package com.itmuch.cloud.moviecustomer.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import com.itmuch.cloud.moviecustomer.entity.User;
import com.itmuch.cloud.moviecustomer.feign.UserConfigFeign;

@RestController
public class UserConfigController {
	@Autowired
	@LoadBalanced
	private RestTemplate restTemplate;
	
	
	@Autowired
	private UserConfigFeign userConfigFeign;
	
	@GetMapping("/findUserByid/{id}")
	public User findById(@PathVariable Long id) {
		return restTemplate.getForObject("http://movie-service/findUserByid/"+id, User.class);
	}
	

	/**
	 * 通过feign自定义配置方式实现
	 * @param id
	 * @return
	 */
	@GetMapping("/getUserByidConfig/{id}")
	public User getUserByidConfig(@PathVariable Long id) {
		return userConfigFeign.findUserByid2(id);
	}
	
	
}
